/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sim_test;

import javax.swing.*;
import java.awt.Dimension;
import java.awt.*;
import javax.swing.OverlayLayout;
/**
 *
 * @author Administrator
 */
public class Sim_JPanelMain extends JPanel {
    
    //Fields
    private Sim_ControllerMain simControllerMain;
    private Sim_JPanelGraphics jPanelGraphics;
    private Sim_JPanelGrid jPanelGrid;
    private Sim_JPanelBackground jPanelBackground;
    private Container mainContainer;
    private OverlayLayout overlayLayout;
    private boolean isGridVisible;
    
    public Sim_JPanelMain(Sim_ControllerMain scm, Dimension size)
    {
        //saving variables
        simControllerMain = scm;
        
        //object creation
        mainContainer = 
        jPanelGraphics = new Sim_JPanelGraphics(simControllerMain, new Dimension(size));
        jPanelGrid = new Sim_JPanelGrid(simControllerMain, new Dimension(size));
        jPanelBackground = new Sim_JPanelBackground(
                simControllerMain.getCurrentScenario().getSimMap().
                getBackgroundImage(), new Dimension(size));
        overlayLayout = new OverlayLayout(this);
        
        
        //set layout
        setLayout(overlayLayout);
        
        //add comp
        addContent();
        
        //varible change
        setPreferredSize(size);
        
        
    }
    
    private void createLayout()
    {
        
    }
    
    private void addContent()
    {
        
        //add(jPanelGrid, new Integer(2));
        //add(jPanelGraphics, new Integer(3));
        //add(jPanelBackground, new Integer(5));
        
        
        System.out.println(getRootPane());
        
        add(jPanelGrid);
        add(jPanelGraphics);
        add(jPanelBackground);
        
        
        
    }
    
  
    
    public void toggleShowGrid()
    {
        if(isGridVisible)
        {
            jPanelGrid.setVisible(false);
        }
        
        else
        {
            jPanelGrid.setVisible(true);
        }
    }

}
